package com.tjetc;

import com.tjetc.utils.JdbcUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 * @ author: gaoyongxiang
 * @ date: 2025/8/15
 * @ version: v1.0
 */
public class _3ResultSet {
    public static void main1(String[] args) throws SQLException {
        /*
            结果集对象：ResultSet
         */
        Connection connection = JdbcUtil.getConnection();
        String sql = "select * from bank";
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery(sql);
        while (resultSet.next()) {
            int id = resultSet.getInt(1);
            String name = resultSet.getString(2);
            System.out.println(name);
            System.out.println(id);
        }

        JdbcUtil.close(resultSet, statement, connection);

    }

}